package com.dzwww.recommend.rule.common.po.base;


import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.dzwww.recommend.rule.util.validator.ValidatorGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 *  公共实体
 * <p>
 *   @author lixin
 *   @date 2018/3/28 下午2:50
 *   @version 1.0
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public abstract class BaseEntity extends Model<BaseEntity> implements Serializable {

    private static final long serialVersionUID = 3604321486155854026L;

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "id不能为空", groups = ValidatorGroup.Update.class)
    protected Long id;

    /**
     * 为额外的信息预留的字段
     */
    @TableField(fill = FieldFill.INSERT)
    private String feature;

    /**
     * 状态，暂未用到该字段
     */
    @TableField(fill = FieldFill.INSERT)
    protected Integer status;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    protected Date gmtCreate;

    /**
     * 修改时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT, update = "now()")
    protected Date gmtModified;

    @Override
    protected Serializable pkVal() {
        return id;
    }

}
